#!/usr/bin/env python
# encoding: utf-8

"""Server class integrated with Spyro.
It's based on wsgiref.simple_server to provide a quick way to serve your
application during development.

Remember it's not made to run in a deployment environment.

For the distribution of your application you may choose by different
PEP-3333 ready webservers, I suggest you to give a look to uWSGI [1]

[1] http://projects.unbit.it/uwsgi/
"""

from wsgiref.simple_server import make_server

class Serve:
    """Simple class to serve the wsgi application made for development
    purpose.
    """
    
    def __init__(self, application, host='127.0.0.1', port=8080):
        
        print("Starting on http://%(host)s:%(port)s/" % locals())
        try:
            make_server(host, port, application).serve_forever()
        except KeyboardInterrupt:
            print("\nStopping the webserver...")
